<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>开关效果</title>
  <style>
    div {
      width: 40px;
      height: 20px;
      background-color: #3F9EFF;
      display: flex;
      /* 边框和背景色一样 */
      border: 2px solid #3F9EFF;
      /* 外边框圆角半径 */
      border-radius: 10px;
      /* 总宽度和总高度：包含边框 和 内边距 */
      box-sizing: border-box;
      /* 鼠标指针变成小手 */
      cursor: pointer;
    }

    span {
      width: 16px;
      height: 16px;
      border-radius: 8px;
      background-color: #fff;
    }
  </style>
</head>

<body>
  <div>
    <span></span>
  </div>
</body>

</html>